package edu.hrbu.spring.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.hrbu.spring.mapper.UserMapper;
import edu.hrbu.spring.pojo.User;
import edu.hrbu.spring.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 徐登宇
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource(name = "userMapper")
    UserMapper userMapper;

    @Override
    public List<User> getAllUsersPage(int page, int size) {
        PageHelper.startPage(page, size);
        List<User> userList = userMapper.getAllUsersPage();
        PageInfo<User> userPageInfo = new PageInfo<>(userList);
        System.out.println(userPageInfo);
        return userPageInfo.getList();

    }
}
